package com.hrzyit.whistle.cases.service.impl

import com.hrzyit.base.data.protocol.ApiPageInfo
import com.hrzyit.base.ext.convert
import com.hrzyit.base.ext.convertBoolean
import com.hrzyit.whistle.cases.data.bean.*
import com.hrzyit.whistle.cases.data.repository.CaseCenterRepository
import com.hrzyit.whistle.cases.service.ICaseCenterService
//import rx.Observable
import io.reactivex.Observable
import javax.inject.Inject


/**
 * 案件管理服务接口实现类
 * @author YangWei
 * @date 2019/4/1
 */
class CaseCenterServiceImpl @Inject constructor() : ICaseCenterService {
    @Inject
    lateinit var caseCenterRepository: CaseCenterRepository

    override fun getDeptUserForApproveList(
        caseId: Long,
        userId: Long
    ): Observable<MutableList<SelectUserDeptInfoVo>> {
        return caseCenterRepository.getDeptUserForApproveList(caseId, userId).convert()
    }

    override fun getCaseAuthInfo(caseId: Long, userId: Long): Observable<AuthMsgEntityVo> {
        return caseCenterRepository.getCaseAuthInfo(caseId, userId, 0L).convert()
    }


    override fun caseApply(entity: CaseInfoEntity): Observable<MutableMap<String, Any>> {
        return caseCenterRepository.caseApply(entity).convert()
    }

    override fun selectCaseListByCaseType(
        caseType: Int,
        currentPage: Int,
        pageSize: Int
    ): Observable<ApiPageInfo<CaseInfoEntity>> {
        return caseCenterRepository.selectCaseListByCaseType(caseType, currentPage, pageSize).convert()

    }

    override fun getCaseInfoById(caseId: Long): Observable<CaseDetailInfoEntity> {
        return caseCenterRepository.getCaseInfoById(caseId).convert()
    }

    override fun signInCaseFromCenter(caseSignInVo: CaseSignInVo): Observable<Boolean> {
        return caseCenterRepository.signInCaseFromCenter(caseSignInVo).convertBoolean()
    }

    override fun selectCaseDispatchUserList(caseId: Long, userId: Long): Observable<MutableList<CaseIndexUserInfoVo>> {

        return caseCenterRepository.selectCaseDispatchUserList(caseId, userId).convert()
    }

    override fun selectCaseTransferDeptList(caseId: Long, userId: Long): Observable<MutableList<CaseIndexDeptInfoVo>> {

        return caseCenterRepository.selectCaseTransferDeptList(caseId, userId).convert()
    }

    override fun saveCaseDisposeUser(
        caseId: Long,
        userId: Long,
        disposeDeptId: Long,
        disposeUserId: Long
    ): Observable<Boolean> {
        return caseCenterRepository.saveCaseDisposeUser(caseId, userId, disposeDeptId, disposeUserId).convertBoolean()
    }

    override fun saveCaseDisposeResult(saveDisposeCaseInfoVo: SaveDisposeCaseInfoVo): Observable<Boolean> {
        return caseCenterRepository.saveCaseDisposeResult(saveDisposeCaseInfoVo).convertBoolean()
    }

    override fun applyCaseClose(caseApplyCloseVo: CaseApplyCloseVo): Observable<Boolean> {
        return caseCenterRepository.applyCaseClose(caseApplyCloseVo).convertBoolean()
    }

    override fun saveAuthMsg(authMsgEntity: AuthMsgEntity): Observable<Boolean> {
        return caseCenterRepository.saveAuthMsg(authMsgEntity).convertBoolean()
    }

    override fun selectCaseTransferUserList(
        caseId: Long,
        userId: Long,
        deptId: Long
    ): Observable<MutableList<CaseIndexUserInfoVo>> {
        return caseCenterRepository.selectCaseTransferUserList(caseId, userId, deptId).convert()
    }

    override fun signInCaseFromDept(caseSignInVo: CaseSignInVo): Observable<Boolean> {
        return caseCenterRepository.signInCaseFromDept(caseSignInVo).convertBoolean()
    }

    override fun saveTransferCaseToDept(transferCaseToDeptVo: TransferCaseToDeptVo): Observable<Boolean> {
        return caseCenterRepository.saveTransferCaseToDept(transferCaseToDeptVo).convertBoolean()
    }

    override fun getCaseInfoProcessListByCaseId(caseId: Long): Observable<MutableList<CaseInfoProcessVo>> {
        return caseCenterRepository.getCaseInfoProcessListByCaseId(caseId).convert()
    }

    override fun applyCaseWhistle(whistleCase: WhistleCaseVo): Observable<Boolean> {
        return caseCenterRepository.applyCaseWhistle(whistleCase).convertBoolean()
    }
}